<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script type="text/javascript" src="/js/reqToken.js"></script>
    <script src="/js/jquery.min.js"></script>
    <script>
        function getTest() {
            $.ajax({
                type: 'post',
                url: 'http://api.hk.com/s/test',
                data: JSON.stringify({
                    "email": "2568425312@qq.com",
                    "password": "123456"
                }),
                contentType: 'application/json;charset=utf-8',
                success: function (res) {
                    console.log(res);
                    $("#test").html(JSON.stringify(res));
                    return false;
                },
                error: function () {
                    alert('请求错误');
                    return false;
                }

            });
        }

        function postTest() {
            $.ajaxSetup({
                type: 'post',
                url: 'http://api.hk.com/s/test1',
                beforeSend: function (XMLHttpRequest) {
                    XMLHttpRequest.setRequestHeader("Authorization", "bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIyNTY4NDI1MzEyQHFxLmNvbSIsImNyZWF0ZWQiOjE2MjcyNzAyNTE1OTQsImV4cCI6MTYyNzM0MjI1MX0.jham3kL62F3MpTwBaR011OL5R4Tadtb_3jYunZlRTFYFl8B7o8g59qnLlCMFKoQfD2U-u4KSHFOuRe23yADaTg");
                },
                success: function (res) {
                    console.log(res);
                    $("#test").html(JSON.stringify(res));
                    return false;
                },
                error: function (res) {
                    alert('请求错误');
                    $("#test").html(JSON.stringify(res));
                    return false;
                }

            });
            $.ajax();
        }
    </script>
</head>

<body>
    <button onclick="getTest()">Get</button>
    <button onclick="postTest()">POST</button>
    <p id="test"></p>
</body>

</html>